package com.ds.common.log;

import com.ds.common.nacos.ConfigModel;
import com.ds.common.nacos.NacosConfig;
import lombok.Data;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;

/**
 * @author WeiShaoying
 */
@Component
public class LogSwitch extends NacosConfig<LogSwitch.LogConfig> {

    @Override
    protected String getDataId() {
        return "log-config";
    }

    @Override
    protected String getGroupId() {
        return "vs";
    }

    @Override
    protected Class<LogConfig> getClassType() {
        return LogConfig.class;
    }
    @PostConstruct
    public void initStatic() {
        logSwitch = this;
    }

    private static LogSwitch logSwitch;

    public static LogConfig getConfig() {
        return logSwitch.getValue();
    }


    @Data
    public static class LogConfig implements ConfigModel {
        public  String logLevel = "info";
        public  boolean openLogWriter = false;
    }
}
